package org.jeecg.glr.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.glr.entity.GlrLedTaskBinding;
import org.jeecg.glr.mapper.GlrLedTaskBindingMapper;
import org.jeecg.glr.service.IGlrLedTaskBindingService;
import org.jeecg.glr.util.StringUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 定时任务绑定表
 * @Author: jeecg-boot
 * @Date:   2020-04-27
 * @Version: V1.0
 */
@Service
public class GlrLedTaskBindingServiceImpl extends ServiceImpl<GlrLedTaskBindingMapper, GlrLedTaskBinding> implements IGlrLedTaskBindingService {

    @Resource GlrLedTaskBindingMapper glrLedTaskBindingMapper;

    @Override
    public void bingLed(GlrLedTaskBinding domain) {
        if(StringUtil.isNotEmpty(domain.getIds())){
            String [] ids=domain.getIds().split(",");
            for(int i=0;i<ids.length;i++){
                if(StringUtil.isNotEmpty(ids[i])){
                    GlrLedTaskBinding r = new GlrLedTaskBinding();
                    r.setLedCode(ids[i]);
                    r.setLedTaskId(domain.getLedTaskId());
                    super.save(r);
                }
            }
        }
    }

    @Override
    public List<String> getLedByTaskId(String ledTaskId) {
        return glrLedTaskBindingMapper.getLedByTaskId(ledTaskId);
    }
}
